<template>
	<scroll-view scroll-y class="bg-sv bg-color padding-sm">
		<view class="cu-list menu">
			<view class="cu-item bg-color">
				<view class="content">
					<text class="cuIcon-settingsfill text-color"></text>
					<text v-for="(item,index) in categorys" 
						:key="index" 
						
						class="text-color"><text v-if="index > 0">/</text>{{item.name.replaceAll("■", "")}}</text>
				</view>
			</view>
			<view class="cu-item bg-color">
				<view class="content">
					<text class="cuIcon-upstage text-color"></text>
					<text class="text-color">{{product.name}}</text>
				</view>
			</view>
			
			<view class="cu-item bg-color">
				<view class="content">
					<text class="cuIcon-recharge text-color"></text>
					<text class="text-color">{{this.util.parseMoney(product.price, coverImage)}}</text>
				</view>
			</view>
		</view>
		<view class="">
			<u-parse :content="product.contant">
			</u-parse>
		</view>
	</scroll-view>
</template>

<script>
	import uParse from '@/components/u-parse/u-parse.vue'
	export default {
		components: {
		    uParse
		  },
		data: function() {
			return {
				product: {
					productId: 0,
				},
				coverImage: {},
				image: [],
				categorys: []
			};
		},
		onLoad: function(option) {
			console.log(option.productId);
			let self = this;
			this.http.get({
				url: "/product/info",
				param: {
					productId: option.productId
				}
			}).then(res => {
				console.log(res);
				this.product = res.product;
				this.coverImage = res.coverImage;
				this.product = res.product;
				
				this.categorys = JSON.parse(this.product.categorys);
			});
		},
		methods: {
			viewImage(e) {
				let urls = [];
				for (let index in this.product.imgs) {
					urls.push(this.product.imgs[index].url);
				}
				uni.previewImage({
					urls,
					current: e.currentTarget.dataset.index
				});
			},
		}
	}
</script>

<style scoped>
	
</style>
